package com.qinglei.recoup.system.manager.adapter.impl;


import com.fasterxml.jackson.databind.JsonNode;
import com.qinglei.recoup.common.domain.RadarMessage;
import com.qinglei.recoup.system.manager.BreathHeartAlarmV7;
import com.qinglei.recoup.system.manager.adapter.RadarVersionAdapter;
import com.qinglei.recoup.system.service.BedService;
import com.qinglei.recoup.system.service.RadarDataService;
import com.qinglei.recoup.system.service.RadarService;
import com.qinglei.recoup.system.util.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: 最爱学英语的cxd
 * @slogan: 一入代码深似海，从此红尘是路人
 * @create: 2022-05-05
 **/
@Slf4j
@Service
public class RadarV7Adapter implements RadarVersionAdapter {

    @Resource
    private RadarService radarService;

    @Resource
    private BedService bedService;

    @Resource
    private BreathHeartAlarmV7 breathHeartAlarmV7;

    @Resource
    private RadarDataService radarDataService;

    @Override
    public void handleDRadarData(RadarMessage message) {
        JsonNode jsonNode = JSONUtil.jsonToNode(message.getData());
//                jsonNode.with().put();
        //将类型写入map
        radarDataService.saveRadarUserData(message);
        radarService.updateOnlineStatus(message.getSn());
        radarService.updateNetworkStatus(message.getSn());
        bedService.procRadarDataV7(jsonNode,message.getType());
        breathHeartAlarmV7.updateBreathStatus(jsonNode);
    }
}
